package cn.tude.websocket.websocket.service.impl;

import cn.tude.websocket.websocket.mapper.WebSocketMapper;
import cn.tude.websocket.websocket.pojo.dto.HistoryQuery;
import cn.tude.websocket.websocket.pojo.entity.Message;
import cn.tude.websocket.websocket.pojo.vo.MessageVO;
import cn.tude.websocket.websocket.service.WebSocketService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Slf4j
@Service
public class WebSocketServiceImpl implements WebSocketService {

    private static WebSocketMapper webSocketMapper;
    @Autowired
    public void setINoticeService(WebSocketMapper webSocketMapper) {
        WebSocketServiceImpl.webSocketMapper = webSocketMapper;
    }

    @Override
    public void saveMessage(Message message) {
        log.debug("webSocketMapper={}",webSocketMapper);
        webSocketMapper.saveMessage(message);
    }

    @Override
    public List<MessageVO> getHistory(HistoryQuery historyQuery) {
        List<MessageVO> list = webSocketMapper.getHistory(historyQuery);
        return list;
    }
}
